from app import create_app
from models.demo import Person
from service.demoService import DemoService



app = create_app()

def test_query_person_by_id():
    person_id = 2
    result = DemoService.query_person_by_id(person_id)
    print(f'result:{result}')

def test_add_person():
    person = Person()
    person.name="张三"
    person.address="上海"

    result =  DemoService.add_person(person)
    print(f'result:{result}')

def test_del_person_by_id():
    person_id = 1
    result = DemoService.del_person_by_id(person_id)

    print(f'result:{result}')

def test_update_person():
    person_dict = {
        "id":2,
        "name":"张三",
        "address":"上海+"
    }
    # print(person_dict['id'])

    result =  DemoService.update_person(person_dict)
    print(f'result:{result}')

with app.app_context():
    # test_add_person()

    # test_query_person_by_id()

    test_update_person()

    # test_del_person_by_id()
